package com.example.client_anna.base;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cy
 * @email 272884043@qq.com
 * @date 2021/10/19
 */
//ActivityCollector类用于管理所有的活动
public class ActivityCollector {

    public static List<Activity> activities = new ArrayList<>();
    //添加类
    public static void addActivity(Activity activity){
        activities.add(activity);
    }
    //移除类
    public static void removeActivity(Activity activity){
        activities.remove(activity);
    }
    //移除全部活动实现强制下线功能
    public static void finishAll(){
        for (Activity activity : activities){
            if(!activity.isFinishing()){
                activity.finish();
            }
        }
    }

}
